package com.zb.vo;

import com.zb.entity.ZjCustomer;
import com.zb.utils.VerificUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.beans.BeanUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * @Author WEN
 * @Date 2023/7/19 0019
 **/
@Data
@ApiModel("注册企业实体")
public class CustomerRegisterVo {
    @NotBlank(message = "企业名称不能为空")
    @Length(max = 200, message = "企业名称字符长度限制在200个以内")
    @ApiModelProperty(value = "企业名称", required = true)
    private String name;

    @NotBlank(message = "企业简称不能为空")
    @Length(max = 50, message = "企业简称字符长度限制在50个以内")
    @ApiModelProperty(value = "企业简称", required = true)
    private String abbrevia;

    @NotBlank(message = "姓名不能为空")
    @Length(max = 100, message = "姓名字符长度限制在100个以内")
    @ApiModelProperty(value = "人员名称", required = true)
    private String username;

    @NotBlank(message = "手机号不能为空")
    @Pattern(regexp = VerificUtil.REGEX_PHONE, message = "手机号格式不正确！")
    @ApiModelProperty(value = "手机号", required = true)
    private String phone;

    @ApiModelProperty(value = "联系电话")
    private String telephone;

    @ApiModelProperty(value = "传真")
    private String fax;

    @Length(max = 50, message = "地址-省字符长度限制在 50 个以内")
    @ApiModelProperty(value = "省")
    private String province;

    @Length(max = 50, message = "地址-市字符长度限制在 50 个以内")
    @ApiModelProperty(value = "市")
    private String city;

    @Length(max = 50, message = "地址-县/区字符长度限制在 50 个以内")
    @ApiModelProperty(value = "县/区")
    private String area;

    @Length(max = 50, message = "地址-镇字符长度限制在 50 个以内")
    @ApiModelProperty(value = "镇")
    private String town;

    @Length(max = 200, message = "详细地址字符长度限制200个以内")
    @ApiModelProperty(value = "详细地址")
    private String address;

    public static ZjCustomer voToBean(CustomerRegisterVo vo) {
        ZjCustomer customer = new ZjCustomer();
        BeanUtils.copyProperties(vo, customer);
        customer.setFullName(vo.getName());
        return customer;
    }

}
